#!/usr/bin/perl

# Test authenticator using environment method.  Logins will be accepted if
# the login and the password are identical, and will be rejected otherwise.
#
# Generally the environment method is not recommended.  Use the pipe method
# instead.
#
# This authenticator does copious logging by writing all sorts of stuff to
# STDERR.  A production authenticator would not normally do this, and it
# *especially* would not write the plain text password out to the log file.

# Get the name of this program
$prog= join ' ',$0,@ARGV;

# Get the user name
$user= $ENV{USER};

# Get the password name
$pass= $ENV{PASS};

# Dump the environment to the error_log file
foreach $env (keys(%ENV))
{
	print STDERR "$prog: $env=$ENV{$env}\n";
}

# Accept the login if the user name matchs the password
if ($user eq $pass)
{
	print STDERR "$prog: login matches password - Accepted\n";
	exit 0;
}
else
{
	print STDERR "$prog: login doesn't match password - Rejected\n";
	exit 1;
}
